#ifndef MAINHANDLER_H
#define MAINHANDLER_H

#include <BLineArray>
#include <BViewer>
#include <BBillboard>
#include <BLine>
#include <BQuad>
#include <BCone>
#include <BSphere>
#include <BPicker>
#include <BSurface>
#include <BRoundHandler>

#include "DragHandler.h"

class MainHandler : public BRoundHandler
{
public:
	MainHandler();
	~MainHandler();

	void setDragImpulse(BReal dragImpulse);
	BReal dragImpulse() const;

	void showSleeps(bool onoff);
	void showContacts(bool onoff);
	void showOnlyDynamicBodys(bool onoff);

protected:
	void drawPickedFeature(BRender& render, BPickHit* hit);

protected:
	virtual void attached(BViewer* viewer);
	virtual void detached(BViewer* viewer);

	virtual void render(BRender& render);

	virtual void updateEvent(const BEvent& event);
	virtual void freshEvent(const BEvent& event);

	virtual void keyPressEvent(const BKeyEvent& keyEvent) override;
	virtual void keyReleaseEvent(const BKeyEvent& keyEvent) override;

	virtual void mouseEnterEvent(const BMouseEvent& mouseEvent);
	virtual void mouseLeaveEvent(const BMouseEvent& mouseEvent);
	virtual void mousePressEvent(const BMouseEvent& mouseEvent);
	virtual void mouseReleaseEvent(const BMouseEvent& mouseEvent);
	virtual void mouseMoveEvent(const BMouseEvent& mouseEvent);

protected:
	BHolder<BNode>			_selectedNode;
	bool					_spaceShown;
	bool					_showSleeps;
	bool					_showContacts;
	bool					_showOnlyDynamicBodys;

	BHolder<DragHandler>	_dragHandler;

	BHolder<BPickHit>		_hoveredHit;
	BVector					_hoveredPoint;
	BHolder<BNode>			_hoveredNode;
	BHolder<BShape>			_hoveredShape;
	bool					_leftPressed;
	BLine					_linePressed;
	int						_transStep;
	BSpace					_transSpace;
};

#endif